package Messages;

	import java.io.IOException;
	import java.sql.SQLException;
	import java.util.ArrayList;

	import Server.SQLConnection;

	import com.mysql.jdbc.ResultSet;
	import com.mysql.jdbc.Statement;

	import ocsf.server.ConnectionToClient;
	/**
	 * This class implements order Reservation from the DB
	 *   @author Shlomit Yosfan
	 * @author Nofar Sutliman
	 */
	public class MessageReservation {

		private ConnectionToClient client ;
		private String[] str;
		static int row1;
	/**
	 * Constructor of this class 	
	 * @param str
	 * @param client
	 */
	public MessageReservation(String[] str, ConnectionToClient client){
			
			this.client= client ;
			this.str= str; 
		}//end of constractor
	/**
	 * View  Reservation to the DB	
	 * @throws SQLException
	 * @throws IOException
	 */
	public void View() throws SQLException, IOException
	{
		
		Statement stmt;
		SQLConnection conn = new  SQLConnection();

		java.sql.PreparedStatement ps = conn.getConnection().prepareStatement("SELECT * FROM db.reservation ;");
		ResultSet rs= (ResultSet) ps.executeQuery();
		
		ArrayList<Object> res =new ArrayList<Object>();
		res.add("Reservation");
		while (rs.next())
		{
			res.add(rs.getInt(1));
			res.add(rs.getString(2));
			res.add(rs.getString(3));
			res.add(rs.getString(4));
			res.add(rs.getString(5));
			res.add(rs.getString(6));
			res.add(rs.getString(7));
			res.add(rs.getString(8));
			
		}
		client.sendToClient(res);
	  }
		
	}

